﻿/***************************************************************************
//* Foxit Software Inc.
//* Copyright(C) 2005-2012, all rights reserved.
//*
//* The following code is copyrighted and contains proprietary information
//* and trade secrets of Foxit Software Inc.                                                      *
***************************************************************************/
/**
* Annot List
*/
define(function (require, exports, module) {
    var Annot = require('./Annot.js');
    require('./MarkupAnnot.js');
    require('./LinkAnnot.js');
    require('./AnnotFactory');
    FXREADER.PDFData.CPDF_AnnotList = function (iPageIndex) {
        //private members
        var _iPageIndex = iPageIndex,
                 _AnnotList = [],
                 _self = this;

        //public methods
        this.GetAt = function (index) {
            if (isNaN(index))
                return null;
            if (index < 0 || index >= _AnnotList.length)
                return null;
            return _AnnotList[index];
        };
        /** Get the count of annotations in the annotation list. */
        this.Count = function () {
            return _AnnotList.length;
        };

        this.RemoveAll = function () {
            for (var i = 0; i < _AnnotList.length; i++)
                delete this._AnnotList[i];
            _AnnotList = [];
        };

        this.Replace = function (index, pAnnot) {
            if (isNaN(index))
                return false;
            if (index < 0 || index >= _AnnotList.length)
                return false;
            _AnnotList.splice(index, 1, pAnnot);
            return true;
        };

        this.Insert = function (index, pAnnot) {
            if (isNaN(index))
                return false;
            if (index < -1 || index >= _AnnotList.length)
                return false;
            _AnnotList.splice(index, 0, pAnnot);
            return true;
        };

        this.Add = function (pAnnot) {
            _AnnotList.push(pAnnot);
            return true;
        };


        this.Remove = function (annotIndex) {
            if (isNaN(annotIndex) || annotIndex > _AnnotList.length || annotIndex < 0) { return false; }
            delete _AnnotList[annotIndex];
            _AnnotList.splice(annotIndex, 1);
            return true;
        };

        this.GetPageIndex = function () {
            return _iPageIndex;
        };

        this.GetAnnotList = function () {
            return _AnnotList;
        };
    };

    return FXREADER.PDFData.CPDF_AnnotList;


});